import pathlib

from decouple import config

DEBUG = config('DEBUG', True, cast=bool)  # 开发时为True

LOG_FILE_PATH = pathlib.Path(__file__).parent / 'logs' / 'error.log'  # 日志文件路径

# domain
SITE_NAME = config('SITE_NAME', 'example.com')

# most visited book
NUM_SHOW_ITEMS = 10
# NUM_MOST_VIEWED = 20  # 最多人浏览的记录数
# NUM_MOST_RECENT = 10  # 显示最近入库的记录数
# NUM_MOST_POPULAR = 10  # 单月浏览最多显示的记录数

# pagination
PER_PAGE = 5  # 每页多少条记录

# mysql
MYSQL_HOST = config('MYSQL_HOST', '127.0.0.1')
MYSQL_PORT = config('MYSQL_PORT', 3306, cast=int)  # 注意转化为合适类型,否则数据库连接错误
MYSQL_USER = config('MYSQL_USER', 'root')
MYSQL_PASSWORD = config('MYSQL_PASSWORD', 'root')
MYSQL_DB = config('MYSQL_DB', 'test05')  # create database test05

# redis
REDIS_HOST = config('REDIS_HOST', '127.0.0.1')
REDIS_PORT = config('REDIS_PORT', 6379, cast=int)
REDIS_DB = config('REDIS_DB', 0, cast=int)
REDIS_PASSWORD = config('REDIS_PASSWORD', 'root')

# redis设置密码
# config set requirepass "你的密码"
# 查看是否设置成功
# config get requirepass
# 认证
# auth "你的密码"
# 清除密码
# config set requirepass ""
CACHE_EXPIRES = 24 * 60 * 60  # 秒
REDIS_DB_PREFIX = 'rpdf'

SERVER_ERROR_MESSAGE = '页面加载错误，管理员正在解决...'
